/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vale.miniDOM;

import vale.util.AttributeExtractor;
import vale.util.AttributeExtractor.Attribute;

/**
 *
 * @author juan
 */
public final class XMLAttribute {

    private String name;
    private String value;

    private XMLAttribute(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return this.name + "=\"" + this.value + "\"";
    }

    protected static XMLAttribute[] getAttributtes(String tag) {
        Attribute[] externalTypes = null;
        if (tag.endsWith("/>")) {
            externalTypes = AttributeExtractor.extract(tag, ">", "/>");
        } else {
            externalTypes = AttributeExtractor.extract(tag, ">", ">");
        }
        XMLAttribute[] myType = new XMLAttribute[externalTypes.length];
        for (int i = 0; i < externalTypes.length; i++) {
            String name = externalTypes[i].getName();
            String value = externalTypes[i].getValue();
            myType[i] = new XMLAttribute(name, value);
        }
        return myType;
    }
}
